package com.lehecai.ucenter.client;

import net.sf.json.JSONObject;

public class AppResponse {
	public static final String APP_CODE = "code";
	public static final String APP_MESSAGE = "message";
	public static final String APP_DATA = "data";
	
	public static final int APP_CODE_SUCCESS = 1;
	public static final int APP_CODE_FAILURE = 0;
	
	private int code;
	/* 执行结果信息 */
	private String message;
	
	private JSONObject data;
	
	public static AppResponse convertFromJsonString(String jsonString) {
		AppResponse appResponse = new AppResponse();
		JSONObject obj = JSONObject.fromObject(jsonString);
		appResponse.setCode(obj.getInt(AppResponse.APP_CODE));
		appResponse.setMessage(obj.getString(AppResponse.APP_MESSAGE));
		appResponse.setData(obj.getJSONObject(AppResponse.APP_DATA));
		return appResponse;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public JSONObject getData() {
		return data;
	}

	public void setData(JSONObject data) {
		this.data = data;
	}
}
